<%@ page language="java" contentType="text/html" pageEncoding="utf-8"%>
<%@include file="/WEB-INF/pages/common/common.jsp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head> 
    <%@include file="/WEB-INF/pages/common/head.jsp"%>
     <%@include file="/resources/datepicker/datepicker.jsp"%>
    <title><spring:message code="title.ipic.target"/></title>
      <style type="text/css">
        .font_stress{
            color: red;font-size: 13px;font-weight:bold;
        }
    </style>
    <script type="text/javascript">
          var datagrid;
	        $(function() {
	            datagrid=$('#datagrid').datagrid({
	                onClickRow:function(rowIndex){
	                    var rows = datagrid.datagrid('getRows');
	                    for ( var i = 0; i < rows.length; i++) {
	                        datagrid.datagrid('endEdit', i);
	                    }
	                    datagrid.datagrid('beginEdit', rowIndex);
	                }
	            });
	            
	           $('#supplierId').combogrid({
                panelWidth:300,
                idField:'id',
                textField:'code',
                fitColumns:true,
                nowrap:true,
                editable:false,
                pagination:{showPageList:false,showRefresh:false},
                url:'${path}/basedata/supplier/ajaxList.do',
                frozenColumns:[[
                    {field:'id',title:'ID',checkbox:true}
                ]],
                columns:[[
                    {field:'code',title:'供应商代码',width:140},
                    {field:'name',title:'供应商名称',width:160},
                    {field:'linkman',title:'质量负责人',width:140}
                ]],
                onSelect:function(rowIndex, rowData){
                    $("#supplierName").val(rowData['name']);
                }
            });
	            
	        });
	        
	       function save_(){
	       
	       var objName= document.getElementById("chk_updateRequireds");
	       var obj= document.getElementById("selfAssessments");
	       
	        var values= $('#values').numberbox('getValue');
	        
	        if(values==''){
	        		 $.messager.alert('<spring:message code='msg.tip'/>','得分不能为空!');
		            return;
	        }
	        
	        var comments=$('#comments').val(); 
	       
	        var value = $("input[name='xx'][type='radio']:checked").val();
	         var v2 =$("#expireDate1").val();
	          var v3 =$("#selfAssessmentDate").val();
	         var v4=$('#contactPersons').val(); 
	         var v5;
	         if(selfAssessments.checked){
	           	v5=1;
	         }else{
	            v5=0;
	         }
	        if(value==1){
	           var v1 =$("#certificationDate1").val();
		       if(v1==''){
		            $.messager.alert('<spring:message code='msg.tip'/>','认证日期不能为空!');
		            return;
		       }
		       if(v2==''){
		          $.messager.alert('<spring:message code='msg.tip'/>','到期日期不能为空!');
		          return;
		       }
		       
		       if(objName.checked){
     	          $('#updateRequired').val("1");
		       }else{
		          $('#updateRequired').val("0");
		       }
			     $('#certificationType').val(value);
			     $('#certificationDate').val(v1);
			     $('#expiredDate').val(v2);
			     
			     
	        }else if(value==2){
	            
	            var v1=$('#certificationDate2').val(); 
		       if(v1==''){
		            $.messager.alert('<spring:message code='msg.tip'/>','认证日期不能为空!');
		            return;
		       }
		       if(v2==''){
		          $.messager.alert('<spring:message code='msg.tip'/>','到期日期不能为空!');
		          return;
		       }
		       
		       if(objName.checked){
     	          $('#updateRequired').val("1");
		       }else{
		          $('#updateRequired').val("0");
		       }
			     $('#certificationType').val(value);
			     $('#certificationDate').val(v1);
			     $('#expiredDate').val(v2);  
	           
	        }else if(value==3){
		          var v1=$('#certificationDate3').val(); 
			       if(v1==''){
			            $.messager.alert('<spring:message code='msg.tip'/>','认证日期不能为空!');
			            return;
			       }
			       if(v2==''){
			          $.messager.alert('<spring:message code='msg.tip'/>','到期日期不能为空!');
			          return;
			       }
			       
			       if(objName.checked){
	     	          $('#updateRequired').val("1");
			       }else{
			          $('#updateRequired').val("0");
			       }
				     $('#certificationType').val(value);
				     $('#certificationDate').val(v1);
				     $('#expiredDate').val(v2);  
	        }else{
	        		 $('#certificationType').val(value); 
	        	
	        }
	          $('#selfAssessmentDates').val(v3);    
		     $('#contactPerson').val(v4);  
		     $('#selfAssessment').val(v5);
	        $('#comment').val(comments); 
			$('#value').val(values); 
	      
	        var isV =$("#tableForm").form("validate");
            if(!isV) return; 
            
            imonJYRH.showZone();
            var effectData = new Object();
            effectData["qualitySystem"] =  JSON.stringify(imonJYRH.serializeObject($("#tableForm *")));
            
            $.ajax({
                url : '${path}/business/supplier_quality/quality_system/ajaxModify.do',
                 data : effectData,
                 cache : false,
                 async : true,
                 dataType : "json",
                success : function(reMsg) {
                    if(reMsg.success){
                        parent.returnResult();
                        message.show({ msg : reMsg.msg,title : '<spring:message code='msg.tip'/>',showType:'slide'});
                    }else{
                        if(!imonJYRH.isBlank(reMsg.obj)){
                            $.messager.alert('<spring:message code='msg.tip'/>',reMsg['obj']);
                        }else{
                            $.messager.alert('<spring:message code='msg.tip'/>',reMsg['msg']);
                        }
                    }
                    imonJYRH.hideZone();
                }
            });
        }
       function envValue(values){
          if(values==1){
           $('#values').numberbox('setValue',10);
            $('#certificationDate2').val(null);
            $('#certificationDate3').val(null);
          }else if(values==2){
           $('#values').numberbox('setValue',8);
            $('#certificationDate1').val(null);
            $('#certificationDate3').val(null);
          }else if(values==3){
            $('#certificationDate1').val(null);
            $('#certificationDate2').val(null);
           $('#values').numberbox('setValue',0);
          }else{
           $('#certificationDate1').val(null);
            $('#certificationDate2').val(null);
             $('#certificationDate3').val(null);
             $('#expireDate1').val(null);
           $('#values').numberbox('setValue',0);
          }
       }
    </script>
</head>
 <body class="easyui-layout">
<div data-options="region:'center'">
    <div class="datagrid-toolbar" style="height:480px">
       <table width="100%" id="tableForm">
                <tr>
                    <td align="right">SupplierCode供应商编码：</td>
                    <td>
                        <input type="text" id="supplierId" name="supplierId" disabled data-options="required:true" value="${vo.supplierId}"/>
                    </td>
                    <td align="right">SupplierName供应商名称：</td>
                    <td>
                        <input type="text" disabled name="supplierName" id="supplierName" value="${vo.supplierName}"/>
                    </td>
                   <!-- <td align="right">Supplier Type供应商类型：</td>
                    <td>
                        <input type="text"  name="type" disabled/>
                    </td>-->
                     <input type="hidden"  name="certificationType" id="certificationType"/>
                     <input type="hidden"  name="certificationDates" id="certificationDate"/>
                     <input type="hidden"  name="expiredDates" id="expiredDate"/>
                     <input type="hidden"  name="updateRequired" id="updateRequired"/>
                     <input type="hidden"  name="value" id="value"/>
                     <input type="hidden"  name="comment" id="comment"/>
                     <input type="hidden"  name="selfAssessment" id="selfAssessment"/>
                     <input type="hidden"  name="contactPerson" id="contactPerson"/>
                     <input type="hidden"  name="selfAssessmentDates" id="selfAssessmentDates"/>
                     <input type="hidden"  name="id" id="id" value="${vo.id}"/>
                </tr>
            </table>

        <br/>
        <div class="font_stress" align="center">
            QM-System(10 POINTS)
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            Evaluation Value：
            <input type="text" id="values" class="easyui-numberbox" data-options="required:true" value="${vo.value}" readOnly="true"/>
        </div>
        <br/>
        <hr width="800px"/>
        <table>
            <tr>
                <td width="550px">
                    <table width="100%">
                        <tr>
                            <td align="right"></td>
                            <td></td>
                            <td><label style="font-weight:bold;">Certification Date</label></td>
                        </tr>
                        <tr>
                            <td align="right">
                                <label for="radio_1">TS16949 认证<br/>TS16949registered</label>
                            </td>
                            <td>
                                <input type="radio" style="width: 10px;" name="xx" id="radio_1"  onclick="envValue(1)" value="1" 
                                   <c:if test="${vo.certificationType==1}">
	                    				checked=true
	                  			    </c:if>
                                >
                            </td>
                            <td>
                                <input type="text" id="certificationDate1"  onFocus="WdatePicker({isShowClear:false,isShowToday:false,readOnly:true})" class="field Wdate" 
                                <c:if test="${vo.certificationType==1}">
	                    				value="${vo.certificationDates}"
	                  			    </c:if>/>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <label for="radio_2">DIN ISO 9001 认证<br/>DIN ISO 9001 registered</label>
                            </td>
                            <td>
                                <input type="radio" style="width: 10px;" name="xx" id="radio_2"  onclick="envValue(2)" value="2"
                                <c:if test="${vo.certificationType==2}">
	                    				checked=true
	                  			    </c:if>
                                >
                            </td>
                            <td>
                                <input type="text"  onFocus="WdatePicker({isShowClear:false,isShowToday:false,readOnly:true})" class="field Wdate" id="certificationDate2" <c:if test="${vo.certificationType==2}">
	                    				value="${vo.certificationDates}"
	                  			    </c:if>/>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <label for="radio_3">低于DIN ISO 9001的认证，<br/>供应商不允许交付到上海爱德夏<br/>worse than DIN ISO 9001 is ko criteria, <br/>supplier is not allowed to deliver to SEM</label>
                            </td>
                            <td>
                                <input type="radio" style="width: 10px;" name="xx" id="radio_3"  onclick="envValue(3)" value="3"
                                <c:if test="${vo.certificationType==3}">
	                    				checked=true
	                  			 </c:if>
                                >
                            </td>
                            <td>
                                <input type="text"  onFocus="WdatePicker({isShowClear:false,isShowToday:false,readOnly:true})" class="field Wdate" id="certificationDate3" <c:if test="${vo.certificationType==3}">
	                    				value="${vo.certificationDates}"
	                  			    </c:if>/>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <label for="radio_4">No certified</label>
                            </td>
                            <td>
                                <input type="radio" style="width: 10px;" name="xx" id="radio_4"  onclick="envValue(4)" value="4"
                                 <c:if test="${vo.certificationType==4}">
	                    				checked=true
	                  			 </c:if>
                                >
                            </td>
                            <td>
                            </td>
                        </tr>
                    </table>
                </td>
                <td width="180px">
                    <table width="100%">
                        <tr>
                            <td>
                                <table width="100%">
                                    <thead>
                                    <tr>
                                        <th>Expire Date of Certificate：</th>
                                    </tr>
                                    <tr>
                                        <th><input type="text"  onFocus="WdatePicker({isShowClear:false,isShowToday:false,readOnly:true})" class="field Wdate" id="expireDate1" value="${vo.expiredDates}"/></th>
                                    </tr>
                                    </thead>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label for="chk_updateRequired">Update Required</label>
                                <input id="chk_updateRequireds" type="checkbox" style="width: 10px;" 
                                 <c:if test="${vo.updateRequired==1}">
	                    				checked=true
	                  			 </c:if>
                                />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <br />
        <hr width="800px"/>
        <table width="100%" style="text-align: center">
            <tr>
                <td width="50px"></td>
                <td>
                    <label for="chk_selfAssessment">Self Assessment</label>
                    <input  type="checkbox" style="width: 10px;" id="selfAssessments"   
                                       <c:if test="${vo.selfAssessment==1}">
	                    				checked=true
	                  			 		</c:if>/>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    Contact Person：
                    <input type="text" id="contactPersons" value="${vo.contactPerson}"/>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    Date of self assessment：
                    <input type="text"  onFocus="WdatePicker({isShowClear:false,isShowToday:false,readOnly:true})" class="field Wdate" id="selfAssessmentDate" value="${vo.selfAssessmentDates}"/>
                </td>
            </tr>
        </table>
        <br />
        <hr width="800px"/>
        <table width="100%">
            <tr>
                <td width="200px"></td>
                <td align="right">
                    Comment评论：
                </td>
                <td>
                    <textarea rows="3" cols="40" id="comments" >${vo.comment}</textarea>
                </td>
            </tr>
        </table>
        <br />
        <div align="right">
              <a class="easyui-linkbutton" href="javascript:void(0);" iconCls="icon-save" onclick="save_();"><spring:message code='button.save'/></a>
              <a class="easyui-linkbutton" href="javascript:void(0);" iconCls="icon-no" onclick="parent.operateDialog.dialog('close');"><spring:message code='button.close'/></a>
        </div>
    </div>
</div> 

</body> 
</html>